<template>
	<view class="page">
		<!-- 用户信息 -->
		<view class="user-info">
			<view class="user-data" @click="onUserInfo">
				<view class="portrait-nickname">
					<view class="portrait">
						<image :src="dataInfo.headimg" mode=""></image>
					</view>
					<view class="nickname">
						<text>{{dataInfo.nickname}}</text>
					</view>
				</view>
				<view class="more">
					<text class="iconfont icon-more"></text>
				</view>
			</view>
			<view class="address" @click="onAddress">
				<view class="title">
					<text>地址管理</text>
				</view>
				<view class="more">
					<text class="iconfont icon-more"></text>
				</view>
			</view>
		</view>
		<!-- 设置列表 -->
		<view class="setting-list">
			<!-- <view class="list" @click="onSetting('/pages/AccountSecurity/AccountSecurity')">
				<view class="title">
					<text>账户安全</text>
				</view>
				<view class="more-content">
					<text class="content">密码/支付等管理</text>
					<text class="iconfont icon-more more"></text>
				</view>
			</view> -->
			<view class="list" @click="onSetting('/pages/PaymentdlPassword/PaymentdlPassword?type=1')">
				<view class="title">
					<text>修改登录密码</text>
				</view>
				<view class="more-content">
					<text class="iconfont icon-more more"></text>
				</view>
			</view>
			<view class="list" @click="onSetting('/pages/PaymentdlPassword/PaymentdlPassword?type=2')">
				<view class="title">
					<text>修改支付密码</text>
				</view>
				<view class="more-content">
					<text class="iconfont icon-more more"></text>
				</view>
			</view>
			<!-- <view class="list">
				<view class="title">
					<text>{{phone?'手机号':'绑定手机号'}}</text>
				</view>
				<view class="more-content">
					<text class="iconfont icon-more more"></text>
				</view>
				<button v-if="!phone" @getphonenumber="getPhone" open-type="getPhoneNumber" style="position: absolute;background: transparent;width: 100%;height: 100%;left: 0;top: 0">
					
				</button>
			</view> -->
			<!-- <view class="list" @click="onSetting('/pages/InvoiceList/InvoiceList')">
				<view class="title">
					<text>发票</text>
				</view>
				<view class="more-content">
					<text class="content">添加发票</text>
					<text class="iconfont icon-more more"></text>
				</view>
			</view> -->
			<!-- <view class="list" @click="onSetting('/pages/MyMemberInterest/MyMemberInterest')">
				<view class="title">
					<text>商城会员</text>
				</view>
				<view class="more-content">
					<text class="content">会员专属商品</text>
					<text class="iconfont icon-more more"></text>
				</view>
			</view> -->
		</view>
		<!-- 设置列表 -->
		<view class="setting-list">
			<view class="list" @click="onSetting('/pages/AboutUs/AboutUs')">
				<view class="title">
					<text>关于我们</text>
				</view>
				<view class="more-content">
					<text class="content"></text>
					<text class="iconfont icon-more more"></text>
				</view>
			</view>
			<view class="list" @click="zhuxiao('/pages/AboutUs/AboutUs')">
				<view class="title">
					<text>注销账号</text>
				</view>
				<view class="more-content">
					<text class="content"></text>
					<text class="iconfont icon-more more"></text>
				</view>
			</view>
		</view>
		<!-- 退出 -->
		<view class="quit-login" @click="onQuitLogin">
			<text>退出登录</text>
		</view>
		<!-- 提示框 -->
		<DialogBox ref="DialogBox"></DialogBox>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				dataInfo:''
			};
		},
		onShow() {
			this.getdata()
		},
		methods: {
			/**
			 * 用户信息点击
			 */
			getdata(){
				let that = this
				that.tui.request("api.auth.center/get", "POST", {}, false, false, true).then((res) => {
					if(res.code==1){
						that.dataInfo = res.data
					}
				}).catch((res) => {
					
				})
			},
			onUserInfo() {
				uni.navigateTo({
					url: '/pages/Information/Information'
				})
			},
			getPhone(e){
				console.log(e)
			},
			/**
			 * 地址点击
			 */
			onAddress() {
				uni.navigateTo({
					url: '/pages/AddressList/AddressList',
				})
			},
			/**
			 * 设置列表点击
			 * @param {String} type
			 */
			onSetting(e) {
				uni.navigateTo({
					url:e
				})
			},
			/**
			 * 退出点击
			 */
			onQuitLogin() {
				this.$refs['DialogBox'].confirm({
					title: '提示',
					content: '是否要退出登录?',
					DialogType: 'inquiry',
					animation: 0
				}).then(() => {
					this.tui.toast('退出成功')
					uni.clearStorageSync()
					
					setTimeout(function(){
						uni.navigateBack()
						// uni.reLaunch({
						// 	url:this.tui.loginUrl()+'#/pages/login/login?url='+this.tui.faceUrl()+"&inviter_code="+uni.getStorageSync('refCode')
						// })
					},1000)
				})
			},
			zhuxiao(){
				let that = this
				this.$refs['DialogBox'].confirm({
					title: '提示',
					content: '是否要注销账号?',
					DialogType: 'inquiry',
					animation: 0
				}).then(() => {
					that.tui.request("api.auth.center/write", "POST", {}, false, false, true).then((res) => {
						that.tui.toast(res.info)
						if (res.code == 1) {
							uni.clearStorageSync()
							setTimeout(function(){
								uni.reLaunch({
									url:that.tui.loginUrl()+'#/pages/login/login?url='+that.tui.faceUrl()+"&inviter_code="+uni.getStorageSync('refCode')
								})
							},1000)
						}
					}).catch((res) => {})
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	@import 'Setting.scss';
</style>